package com.jiesen.base.modules.login.jsLoginUser.mapper;

import com.jiesen.base.baseDao.BaseMapper;
import com.jiesen.base.modules.login.jsLoginUser.model.JsLoginUser;
import org.apache.ibatis.annotations.*;

import java.io.Serializable;
import java.util.List;

@Mapper
public interface JsLoginUserDao extends BaseMapper<JsLoginUser> {

    //用户和角色中间表查询
    @Select("select `sys_role_id` from `sys_user_role` where `sys_user_id` = #{uid} ")
    public List<String> findPermissionByRoleid(@Param("uid") Serializable uid);

    //用户和角色中间表的增加
    @Insert("insert into `sys_user_role` ( `sys_user_id` , `sys_role_id` ) values ( #{uid} , #{rid} )")
    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    public int insertRoleByUserId(@Param("uid")Serializable uid,@Param("rid")Serializable rid);

    //用户和角色中间表的删除（单个）
    @Delete("delete from `sys_user_role` where `sys_user_id` = #{uid} and `sys_role_id` = #{rid} ")
    public int deleteRoleByUserId(@Param("uid")Serializable uid,@Param("rid")Serializable rid);

    //用户和角色中间表的删除
    @Delete("delete from `sys_user_role` where `sys_user_id` = #{uid} ")
    public int deleteRoleByUserId(@Param("uid")Serializable uid);
}
